package base.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * Created by Stay on 2017/5/8  15:01.
 */
public class ThreadTest {

    private static class MyThread extends Thread{

        private List<Integer> list;

        public MyThread(List list){
            this.list = list;
        }

        @Override
        public void run() {
            for(int i = 0; i < 10000; i++){
                list.add(i);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ArrayList<Integer> list = new ArrayList<>();           //集合大小不会等于100000
//        Vector<Integer> list = new Vector<>();         //集合大小等于100000
        for(int i = 0; i < 10; i++){
            new MyThread(list).start();
        }
        Thread.sleep(2000);   //休眠两秒
        System.out.println(list.size());
    }

}
